﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Data;

using ShootSearch.Util;
using ShootSearch.Util.Serializers;

using Quartz;
using log4net;

namespace ShootSearch.Core
{
    public interface ISpiderMan : IConfigable, IInterruptableJob, IDisposable
    {
        JobStatus Status { get; }
        string StatusSummary { get; }
        Task Task { get; set; }
        ILog Logger { get; set; }
    }


    public enum JobStatus
    {
        Unstarted,
        Running,
        Stopping,
        Stopped,
        Completing,
        Completed
    }

    [Serializable]
    [TypeConverter(typeof(ExpandableConverter<SpiderManConfig>))]
    public abstract class SpiderManConfig: ICloneable
    {
        public void Save(string path)
        {
            XmlFormatter.ToXmlFile(this, path);
        }

        #region ICloneable Members

        public object Clone()
        {
            string xml = XmlFormatter.ToXml(this);
            return XmlFormatter.FromXml(xml, this.GetType());
        }

        #endregion

        public virtual SpiderManConfig CloneConfig()
        {
            return Clone() as SpiderManConfig;
        }
    }
}
